Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

371
Visualizações
react: ReactGridLayout.children[0].x must be a number

The issue is not similar to the one with the same title.

I am using react hook to create my own dynamic add/remove using this example to create my dynamic add/remove.

As the title suggests, the error message happens when clicking the 'create item' button.

This is my codesandbox link that shows my code and the error. Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue you were having is that your widget state is set as an array of objects but when you were updating that state in the onAddItem function you were setting the it as an object.

Here's the onAddItem function where the widget state is being updated with the previous state and the new state into a new array.

const onAddItem = () => {
    setCounter(counter + 1);
    setWidgetList([
      ...widget,
      {
        i: "chart" + counter,
        x: (widget.length * 2) % (cols || 12),
        y: Infinity, // puts it at the bottom
        w: 2,
        h: 2
      }
    ]);
  };
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda